/**
 * 企业用户service
 * @author 李艳
 */
import httpUtils  from "../../../commons/utils/FeatchUtils";
import {basicUrl} from "../../../configs/DefaultConfig"
import {convertDataToFormData} from "../../../commons/utils/CommonUtils";

/**
 * 保存或者更新一个分配关系
 *
 * param entity 实体对象
 * return 操作结果
 */
export async function savePosition(params={}){
    return httpUtils.postJson(basicUrl+"/employee/save",params);
}
export async function listAllCanAssignEmployeesIncludeSubNode(params={}){
    Object.assign(params,{sortOrders:[{property:'code',direction:'ASC'}],quickSearchProperties:["code","user.userName"]});
    return httpUtils.postJson(basicUrl+"/employee/findByUserQueryParam",params);
}

export async function listAllCanAssignPositionsIncludeSubNode(params={}){
  Object.assign(params,{sortOrders:[{property:'code',direction:'ASC'}],quickSearchProperties:["code","name"]});
  return httpUtils.postJson(basicUrl+"/position/findAllByPositionQueryParam",params);
}
//假分页
export async function listAllCanAssignPositions(params={}){
  return httpUtils.postJson(basicUrl+"/position/listAllCanAssignPositions",params);
}
export async function listAllAssignedPositionsByUser(params=""){
    return httpUtils.get(basicUrl+"/employeePosition/getChildrenFromParentId",params);
}
export async function removeEmployeePosition(params={}){
  return httpUtils.delete(basicUrl+"/employeePosition/removeRelationsByParam",JSON.stringify(params));
}
export async function insertEmployeePosition(params={}){
  return httpUtils.postJson(basicUrl+"/employeePosition/insertRelationsByParam",JSON.stringify(params));
}

/**
 * 获得所有功能角色
 *
 * param positionId
 */
export async function listAllCanAssignFeatureRolesByUser(params=""){
    return httpUtils.get(basicUrl+"/userFeatureRole/getUnassigned",params);
}
/**
 * 获得已分配功能角色
 *
 * param positionId
 */
export async function listAllAssignedFeatureRoles(params=""){
    return httpUtils.get(basicUrl+"/userFeatureRole/getChildrenFromParentId",params);
}
/**
 * 根据userId，featureRoleGroupId获得所有功能角色
 *
 * param positionId，featureRoleGroupId
 */
export async function listAllCanAssignFeatureRolesByRoleGroupAndUser(params={}){
    return httpUtils.get(basicUrl+"/employee/getCanAssignedFeatureRoles",params);
}
export async function removeFeatureRoles(params={}){
    return httpUtils.delete(basicUrl+"/userFeatureRole/removeRelationsByParam",JSON.stringify(params));
}
export async function insertFeatureRoles(params={}){
    return httpUtils.postJson(basicUrl+"/userFeatureRole/insertRelationsByParam",JSON.stringify(params));
}




/**
 * 获得所有数据角色
 *
 * param positionId
 */
export async function listAllCanAssignDataRolesByUser(params=""){
    return httpUtils.get(basicUrl+"/userDataRole/getUnassigned",params);
}
/**
 * 获得已分配数据角色
 *
 * param parentId
 */
export async function listAllAssignedDataRoles(params=""){
    return httpUtils.get(basicUrl+"/userDataRole/getChildrenFromParentId",params);
}

/**
 * 根据userId，dataRoleGroupId获得所有数据角色
 *
 * param
 */
export async function listAllCanAssignDataRolesByRoleGroupAndUser(params={}){
    return httpUtils.get(basicUrl+"/employee/getCanAssignedDataRoles",params);
}
export async function removeDataRoles(params={}){
    return httpUtils.delete(basicUrl+"/userDataRole/removeRelationsByParam",JSON.stringify(params));
}
export async function insertDataRoles(params={}){
    return httpUtils.postJson(basicUrl+"/userDataRole/insertRelationsByParam",JSON.stringify(params));
}

